package worker

import "fmt"

type Engine struct {
	WorkerChan chan Schedule
}

type Schedule struct {
	Title string
	Url   string
}


// 创建通道
func (e *Engine) CreateWorker () {
	e.WorkerChan = make(chan Schedule, 10)
}

// 往队列抛url
func (e *Engine) InWorker (ch Schedule) {
	e.WorkerChan <- ch
}

// 从队列中取url出来解析
func (e *Engine) Run () {
	n := 1
	for {
		select {
		case gameUrl := <-e.WorkerChan:
			fmt.Printf("%d,title: %s, url: %s\n", n, gameUrl.Title, gameUrl.Url)
			n++
		}
	}
}